package com.demo.bean;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class LogHandler implements InvocationHandler {
	private Object target; //被代理对象
	private LogAscpect log = new LogAscpect();//要加入的业务
	public LogHandler(Object target){
		this.target = target;
	}
	//proxy 代理对象  method 要执行方法 args 方法的参数
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		Object returnValue = null;
		log.before();
		returnValue = method.invoke(target, args);//执行目标方法
		log.after();
		return returnValue;
	}

}
